define (require, exports, module) ->

  # 引入页面样式
  require 'mods/zdymk/zdymk_css.css'
  # 引入API服务
  zdymk_api = require "mods/zdymk/zdymk_api"

  require.exports = Vue.extend

    template: require 'mods/zdymk/zdymk_tpl.js'

    data: () ->
      # 首页自定义模块数组
      custom_mk_arr: []
      # 模块的数据
      first_mk_obj: {}
      sec_mk_obj: {}
      third_mk_obj: {}

    methods:

      # 公司动态详情页跳转
      toggleHref: (type) ->
        self = @
        self.$router.push {name:'zdymk_detail', params: {'type': type} }


      # 获取首页自定义模块
      getZdymkList: () ->
        self = @
        params =
          pageNum: 1
          pageSize: 10

        # 获取模块数据
        return zdymk_api.getZdymkList params
          .then (res) ->
            self.custom_mk_arr = res?.body?.data

            if !! self.custom_mk_arr

              firstArr = []
              secArr = []
              thirdArr = []

              for item in self.custom_mk_arr

                if "1" is '' + item?.mk
                  firstArr?.push item

                if "2" is '' + item?.mk
                  secArr.push item

                if "3" is '' + item?.mk
                  thirdArr.push item

              self.first_mk_obj = firstArr[0]
              self.sec_mk_obj= secArr[0]
              self.third_mk_obj = thirdArr[0]

          .catch (err) ->
            console.log err

    mounted: () ->
      self = @
      self.getZdymkList()